package com.dyz.swordFingerOffer;

/**
 * @author: daiyizheng
 * @date: 2021/5/30 14:32
 * @description:
 */
public class CutRope14 {
    public int cutRope(int target) {
        int [] dp = new int [target+1];
        dp[0] = 1;
        dp[1] = 1;
        //dp[i] = dp[i-1]dp[1];
        for(int i =2; i<=target; i++){

            dp[i] = i;//不分割是最大数
            for(int j=1; j<=i-1; j++){ //第一刀可以剪在1 ~ i-1处
                dp[i] = Math.max(dp[i],j * dp[i - j]);
            }
        }
        return dp[target];
    }

    public static void main(String[] args) {
        System.out.println(new CutRope14().cutRope(2));
    }
}
